package com.cbb.lease.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.reflection.MetaObject;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;

/**
 * @program: clms-eighth01
 * @description: 分页配置类
 * @author: 陈斌斌
 * @create: 2021-07-23 19:45
 **/

@Configuration
@MapperScan("com.baomidou.cloud.service.*.mapper*")
public class PageConfig  implements MetaObjectHandler {
    /**
     * mybatis-plus分页插件<br>
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "ad" +
                "dtime", LocalDateTime.class, LocalDateTime.now());
        this.strictInsertFill(metaObject, "shopAddtime", LocalDateTime.class, LocalDateTime.now());
//        this.strictInsertFill(metaObject, "updatetime", LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.strictUpdateFill(metaObject, "updatetime", LocalDateTime.class, LocalDateTime.now());
    }


}
